VDI.sector_size.
Xend work by Tom Wilkie <tom.wilkie@gmail.com>.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
$\mathit{RO}_\mathit{run}$ & {\tt crash\_dumps} & (crashdump ref) Set & list of crash dumps that refer to this disk \\
$\mathit{RW}$ & {\tt virtual\_size} & int & size of disk as presented to the guest (in bytes). Note that, depending on storage backend type, requested size may not be respected exactly \\
$\mathit{RO}_\mathit{run}$ & {\tt physical\_utilisation} & int & amount of physical space that the disk image is currently taking up on the storage repository (in bytes) \\
-$\mathit{RO}_\mathit{ins}$ & {\tt sector\_size} & int & sector size of VDI (in bytes) \\
$\mathit{RO}_\mathit{ins}$ & {\tt type} & vdi\_type & type of the VDI \\
$\mathit{RW}$ & {\tt sharable} & bool & true if this disk may be shared \\
$\mathit{RW}$ & {\tt read\_only} & bool & true if this disk may ONLY be mounted read-only \\
+$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
\hline
\end{longtable}
\subsection{RPCs associated with class: VDI}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_sector\_size}
+\subsubsection{RPC name:~get\_type}
{\bf Overview:}
-Get the sector\_size field of the given VDI.
+Get the type field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} int get_sector_size (session_id s, VDI ref self)\end{verbatim}
+\begin{verbatim} (vdi_type) get_type (session_id s, VDI ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-int
+vdi\_type
}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_type}
+\subsubsection{RPC name:~get\_sharable}
{\bf Overview:}
-Get the type field of the given VDI.
+Get the sharable field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} (vdi_type) get_type (session_id s, VDI ref self)\end{verbatim}
+\begin{verbatim} bool get_sharable (session_id s, VDI ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-vdi\_type
+bool
}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_sharable}
+\subsubsection{RPC name:~set\_sharable}
{\bf Overview:}
-Get the sharable field of the given VDI.
+Set the sharable field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} bool get_sharable (session_id s, VDI ref self)\end{verbatim}
+\begin{verbatim} void set_sharable (session_id s, VDI ref self, bool value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VDI ref } & self & reference to the object \\ \hline
+
+{\tt bool } & value & New value to set \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_read\_only}
+
+{\bf Overview:}
+Get the read\_only field of the given VDI.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} bool get_read_only (session_id s, VDI ref self)\end{verbatim}
\noindent{\bf Arguments:}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~set\_sharable}
+\subsubsection{RPC name:~set\_read\_only}
{\bf Overview:}
-Set the sharable field of the given VDI.
+Set the read\_only field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} void set_sharable (session_id s, VDI ref self, bool value)\end{verbatim}
+\begin{verbatim} void set_read_only (session_id s, VDI ref self, bool value)\end{verbatim}
\noindent{\bf Arguments:}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_read\_only}
+\subsubsection{RPC name:~get\_other\_config}
{\bf Overview:}
-Get the read\_only field of the given VDI.
+Get the other\_config field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} bool get_read_only (session_id s, VDI ref self)\end{verbatim}
+\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, VDI ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-bool
+(string $\rightarrow$ string) Map
}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~set\_read\_only}
+\subsubsection{RPC name:~set\_other\_config}
{\bf Overview:}
-Set the read\_only field of the given VDI.
+Set the other\_config field of the given VDI.
\noindent {\bf Signature:}
-\begin{verbatim} void set_read_only (session_id s, VDI ref self, bool value)\end{verbatim}
+\begin{verbatim} void set_other_config (session_id s, VDI ref self, (string -> string) Map value)\end{verbatim}
\noindent{\bf Arguments:}
{\bf type} & {\bf name} & {\bf description} \\ \hline
{\tt VDI ref } & self & reference to the object \\ \hline
-{\tt bool } & value & New value to set \\ \hline
+{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~add\_to\_other\_config}
+
+{\bf Overview:}
+Add the given key-value pair to the other\_config field of the given VDI.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void add_to_other_config (session_id s, VDI ref self, string key, string value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VDI ref } & self & reference to the object \\ \hline
+
+{\tt string } & key & Key to add \\ \hline
+
+{\tt string } & value & Value to add \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~remove\_from\_other\_config}
+
+{\bf Overview:}
+Remove the given key and its corresponding value from the other\_config
+field of the given VDI. If the key is not in that Map, then do nothing.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void remove_from_other_config (session_id s, VDI ref self, string key)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VDI ref } & self & reference to the object \\ \hline
+
+{\tt string } & key & Key to remove \\ \hline
\end{tabular}
struct xen_vm_record_opt *vm;
struct xen_vdi_record_opt *vdi;
char *device;
- char *image;
bool bootable;
enum xen_vbd_mode mode;
enum xen_vbd_type type;
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_common.h"
#include "xen_crashdump_decl.h"
#include "xen_sr_decl.h"
+#include "xen_string_string_map.h"
#include "xen_vbd_decl.h"
#include "xen_vdi_decl.h"
#include "xen_vdi_type.h"
struct xen_crashdump_record_opt_set *crash_dumps;
int64_t virtual_size;
int64_t physical_utilisation;
- int64_t sector_size;
- char *location;
enum xen_vdi_type type;
bool sharable;
bool read_only;
+ xen_string_string_map *other_config;
} xen_vdi_record;
/**
xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi vdi);
-/**
- * Get the sector_size field of the given VDI.
- */
-extern bool
-xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi);
-
-
/**
* Get the type field of the given VDI.
*/
xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi);
+/**
+ * Get the other_config field of the given VDI.
+ */
+extern bool
+xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi);
+
+
/**
* Set the name/label field of the given VDI.
*/
xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only);
+/**
+ * Set the other_config field of the given VDI.
+ */
+extern bool
+xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config);
+
+
+/**
+ * Add the given key-value pair to the other_config field of the given
+ * VDI.
+ */
+extern bool
+xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * other_config field of the given VDI. If the key is not in that Map, then
+ * do nothing.
+ */
+extern bool
+xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key);
+
+
/**
* Take an exact copy of the VDI; the snapshot lives in the same
* Storage Repository as its parent.
{ .key = "device",
.type = &abstract_type_string,
.offset = offsetof(xen_vbd_record, device) },
- { .key = "image",
- .type = &abstract_type_string,
- .offset = offsetof(xen_vbd_record, image) },
{ .key = "bootable",
.type = &abstract_type_bool,
.offset = offsetof(xen_vbd_record, bootable) },
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_crashdump.h"
#include "xen_internal.h"
#include "xen_sr.h"
+#include "xen_string_string_map.h"
#include "xen_vbd.h"
#include "xen_vdi.h"
#include "xen_vdi_type_internal.h"
{ .key = "physical_utilisation",
.type = &abstract_type_int,
.offset = offsetof(xen_vdi_record, physical_utilisation) },
- { .key = "sector_size",
- .type = &abstract_type_int,
- .offset = offsetof(xen_vdi_record, sector_size) },
- { .key = "location",
- .type = &abstract_type_string,
- .offset = offsetof(xen_vdi_record, location) },
{ .key = "type",
.type = &xen_vdi_type_abstract_type_,
.offset = offsetof(xen_vdi_record, type) },
.offset = offsetof(xen_vdi_record, sharable) },
{ .key = "read_only",
.type = &abstract_type_bool,
- .offset = offsetof(xen_vdi_record, read_only) }
+ .offset = offsetof(xen_vdi_record, read_only) },
+ { .key = "other_config",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_vdi_record, other_config) }
};
const abstract_type xen_vdi_record_abstract_type_ =
xen_sr_record_opt_free(record->sr);
xen_vbd_record_opt_set_free(record->vbds);
xen_crashdump_record_opt_set_free(record->crash_dumps);
+ xen_string_string_map_free(record->other_config);
free(record);
}
bool
-xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
+xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_int;
-
- XEN_CALL_("VDI.get_sector_size");
+ abstract_type result_type = xen_vdi_type_abstract_type_;
+ XEN_CALL_("VDI.get_type");
return session->ok;
}
bool
-xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
+xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
.u.string_val = vdi }
};
- abstract_type result_type = xen_vdi_type_abstract_type_;
- XEN_CALL_("VDI.get_type");
+ abstract_type result_type = abstract_type_bool;
+
+ XEN_CALL_("VDI.get_sharable");
return session->ok;
}
bool
-xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
+xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
abstract_type result_type = abstract_type_bool;
- XEN_CALL_("VDI.get_sharable");
+ XEN_CALL_("VDI.get_read_only");
return session->ok;
}
bool
-xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
+xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi)
{
abstract_value param_values[] =
{
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_bool;
+ abstract_type result_type = abstract_type_string_string_map;
- XEN_CALL_("VDI.get_read_only");
+ *result = NULL;
+ XEN_CALL_("VDI.get_other_config");
return session->ok;
}
}
+bool
+xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)other_config }
+ };
+
+ xen_call_(session, "VDI.set_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
+ };
+
+ xen_call_(session, "VDI.add_to_other_config", param_values, 3, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string,
+ .u.string_val = key }
+ };
+
+ xen_call_(session, "VDI.remove_from_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
bool
xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi)
{
.name_label = "MyRootFS",
.name_description = "MyRootFS description",
.sr = &sr_record,
- .virtual_size = (1 << 21), // 1GiB / 512 bytes/sector
- .sector_size = 512,
+ .virtual_size = (INT64_C(1) << 30), // 1GiB
.type = XEN_VDI_TYPE_SYSTEM,
.sharable = false,
.read_only = false
local_vdi_cfg = {
'name_label': 'gentoo.hvm',
'name_description': '',
- 'location': 'file:/root/gentoo.amd64.hvm.img',
'virtual_size': 0,
- 'sector_size': 0,
'type': 'system',
'parent': '',
'SR_name': 'Local',
'sharable': False,
'read_only': False,
+ 'other_config': {'location': 'file:/root/gentoo.amd64.hvm.img'},
}
local_vbd_cfg = {
vdi_cfg = {
'name_label': 'API_VDI',
'name_description': '',
- 'virtual_size': 100 * 1024 * 1024,
- 'sector_size': 1024,
+ 'virtual_size': 100 * 1024 * 1024 * 1024,
'type': 'system',
'parent': '',
'SR_name': 'QCoW',
local_vdi_cfg = {
'name_label': 'gentoo.amd64.img',
'name_description': '',
- 'location': 'file:/root/gentoo.amd64.img',
'virtual_size': 0,
- 'sector_size': 0,
'type': 'system',
'parent': '',
'SR_name': 'Local',
'sharable': False,
'read_only': False,
+ 'other_config': {'location': 'file:/root/gentoo.amd64.img'},
}
local_vbd_cfg = {
' %(power_state)-10s %(uuid)-36s'
SR_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(physical_size)-10s' \
'%(type)-10s'
-VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\
- '%(sector_size)-8s'
+VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s'
VBD_LIST_FORMAT = '%(device)-6s %(uuid)-36s %(VDI)-8s'
TASK_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(status)-8s %(progress)-4s'
VIF_LIST_FORMAT = '%(name)-8s %(device)-7s %(uuid)-36s %(MAC)-10s'
'vdi-create': [(('--name-label',), {'help': 'Name for VDI'}),
(('--name-description',), {'help': 'Description for VDI'}),
- (('--sector-size',), {'type': 'int',
- 'help': 'Sector size',
- 'default': 0}),
(('--virtual-size',), {'type': 'int',
'default': 0,
- 'help': 'Size of VDI in sectors'}),
+ 'help': 'Size of VDI in bytes'}),
(('--type',), {'choices': ['system', 'user', 'ephemeral'],
'default': 'system',
'help': 'VDI type'}),
if not is_long:
print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
'uuid' : 'UUID',
- 'virtual_size': 'Bytes',
- 'sector_size': 'Sector Size'}
+ 'virtual_size': 'Bytes'}
for vdi in vdis:
vdi_struct = execute(server, 'VDI.get_record', (session, vdi))
name_label = 'VDI 1'
name_description = ''
-virtual_size = 10 * 1024 * 1024
-sector_size = 1024
+virtual_size = 10 * 1024 * 1024 * 1024
type = 'system'
sharable = False
read_only = False
VDI_attr_ro = ['SR',
'VBDs',
'physical_utilisation',
- 'sector_size',
'type']
VDI_attr_rw = ['name_label',
'name_description',
'virtual_size',
'sharable',
- 'read_only']
+ 'read_only',
+ 'other_config']
VDI_attr_inst = VDI_attr_ro + VDI_attr_rw
VDI_methods = [('snapshot', 'VDI')]
def VDI_get_physical_utilisation(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).
- get_physical_utilisation())
-
- def VDI_get_sector_size(self, session, vdi_ref):
- return xen_api_success(self._get_VDI(vdi_ref).sector_size)
+ get_physical_utilisation())
def VDI_get_type(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).type)
self._get_VDI(vdi_ref).read_only = bool(value)
return xen_api_success_void()
+ def VDI_get_other_config(self, session, vdi_ref):
+ return xen_api_success(
+ self._get_VDI(vdi_ref).other_config)
+
+ def VDI_set_other_config(self, session, vdi_ref, other_config):
+ self._get_VDI(vdi_ref).other_config = other_config
+ return xen_api_success_void()
+
# Object Methods
def VDI_snapshot(self, session, vdi_ref):
return xen_api_todo()
'VBDs': [], # TODO
'virtual_size': image.virtual_size,
'physical_utilisation': image.physical_utilisation,
- 'sector_size': image.sector_size,
'type': image.type,
'sharable': image.sharable,
'read_only': image.read_only,
+ 'other_config': image.other_config
})
# Class Functions
SAVED_CFG = ['name_label',
'name_description',
- 'sector_size',
'virtual_size',
'physical_utilisation',
'sharable',
self.sr_uuid = sr_uuid
self.name_label = ""
self.name_description = ""
- self.sector_size = 1024
self.virtual_size = 0
self.physical_utilisation = 0
self.sharable = False
self.read_only = False
self.type = "system"
- self.location = ''
+ self.other_config = {}
def load_config_dict(self, cfg):
"""Loads configuration into the object from a dict.
'name_description': self.name_description,
'virtual_size': self.virtual_size,
'physical_utilisation': self.physical_utilisation,
- 'sector_size': self.sector_size,
'sharable': False,
'readonly': False,
'SR': self.sr_uuid,
- 'location': self.get_location(),
+ 'other_config': self.other_config,
'VBDs': []}
def get_location(self):
self.cfg_path = cfg_path
self.physical_utilisation = psize
self.virtual_size = vsize
- self.sector_size = 512
self.auto_save = True
- self.location = 'tap:qcow:%s' % self.qcow_path
+ self.other_config['location'] = 'tap:qcow:%s' % self.qcow_path
def get_location(self):
- return self.location
+ return self.other_config['location']
class XendLocalVDI(XendVDI):
def __init__(self, vdi_struct):
self.name_description = vdi_struct.get('name_description', '')
self.physical_utilisation = 0
self.virtual_size = 0
- self.sector_size = 0
self.type = vdi_struct.get('type', '')
self.sharable = vdi_struct.get('sharable', False)
self.read_only = vdi_struct.get('read_only', False)
- self.location = vdi_struct.get('location', 'file:/dev/null')
+ self.other_config = vdi_struct.get('other_config', {})
def get_location(self):
- return self.location
+ return self.other_config['location']